<template>
	<view>
		<cu-custom :bgColor="bgColor" :isBack="true">
			<block slot="backText"></block>
			<block slot="content">派工人</block>
		</cu-custom>
		<form id="root">
			<view class="title">
				<view class="num">用户账号</view>

				<view class="name">姓名</view>
			</view>
			<view>
				<view class="uni-list">
					<checkbox-group @change="checkboxChange">
						<label  class="contentd">
							<view class="kuang">
								<checkbox :value="item.employee" :checked="item.checked" />
							</view>
							<view class="num-value">777</view>
							<view class="name-value">5555</view>
						</label>
					</checkbox-group>
				</view>
				
			</view>
				<button class="fott" form-type="submit">确定</button>
			
		</form>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				bgColor: 'bg-green',
				list: [],
				bgVO:null,
				selectList:[],
				employee:'',
				employeeName:'',
				operation:'',
			};
		},
		// onLoad(option) {
		// 	this.bgVO=JSON.parse(option.bgVO);
		// 	this.init()
		// },
		created() {
			
		},
		methods: {
			init: function(e) {//
				let that = this
				let url = 'pp.mcEmployee/mcEmployee/list'
				this.$http.get(url, {
					params: {
						pageNo: 1,
						pageSize: 500,
						operation:that.bgVO.baogong.vornr,
					}
				}).then(res => {
					if (res.data.success) {
						that.list=res.data.result.records
					}
				}).catch(err => {
					console.log(err);
				});
				
			},
			formSubmit:function(e){//返回上一层
				// uni.navigateBack({
					// delta:1
				// })
				// uni.navigateBack({
				// 	url: '/pages/mcloud/baogong?item='+JSON.stringify({baogong:this.baogong,employee:this.employee,employeeName:this.employeeName})
				// })
				var pages = getCurrentPages();
				var prevPage = pages[pages.length - 2]; //上一个页面
				var item={baogong:this.bgVO.baogong,index:this.bgVO.index,employee:this.employee,employeeName:this.employeeName}
				prevPage.$vm.employeeOk(item);//重点$vm
				uni.navigateBack({
				})
			},
			checkboxChange: function(e) {
				var items = this.list,
					values = e.detail.value;
					let employee=''
					let employeeName=''
				for (var i = 0, lenI = items.length; i < lenI; ++i) {
					const item = items[i]
					if (values.includes(item.employee)) {
						employee=employee+item.employee+','
						employeeName=employeeName+item.name+','
						this.$set(item, 'checked', true)
					} else {
						this.$set(item, 'checked', false)
					}
				}
				if(employee!=''){
					employee=employee.substring(0,employee.length-1)
				}
				if(employeeName!=''){
					employeeName=employeeName.substring(0,employeeName.length-1)
				}
				this.employee=employee
				this.employeeName=employeeName

			}
		}
	}
</script>

<style>
	
	
	.uni-list-cell {
		justify-content: flex-start
	}

	.title {
		display: flex;
		flex-direction: row;
		width: 100%;
		background-color: #FFFFFF;
		height: 100rpx;
		font-size: 28px;
	}
	
	.contentd {
		display: flex;
		flex-direction: row
	}

	.num {
		width: 40%;
		text-align: center;
		line-height: 100rpx;
		margin-left: 150rpx;
	}

	.name {
		width: 40%;
		line-height: 100rpx;
		text-align: center;
	}

	.num-value {
		width: 20%;
		text-align: center;
		margin-left: 40rpx;
		line-height: 100rpx;
		
	}

	.name-value {
		width: 20%;
		margin-left: 140rpx;
		line-height: 100rpx;
		text-align: center;
	}
	.kuang {
		width: 20%;
		margin-left: 50rpx;
		line-height: 100rpx;
		text-align: center;
	}
	
	.fott {
		  border-radius:0;
		  position: fixed;
		  bottom: 0;
		  display: flex;
		  width: 100%;
		  justify-content: center;
	}
	
</style>
